import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;


public class OpenFile {
	JFileChooser chooser;
	String DefaultFolder;
	int choice;
	File selectedfile;
	String filePath;
	FileNameExtensionFilter filter;
	
	public OpenFile()
	{
		DefaultFolder =  new JFileChooser().getFileSystemView().
		getDefaultDirectory().toString();
		chooser = new JFileChooser(DefaultFolder);
		filter = new FileNameExtensionFilter("Excel File", "xlsx");
		chooser.setFileFilter(filter);
		choice = chooser.showOpenDialog(null);
		switch(choice)
		{
			case JFileChooser.APPROVE_OPTION :
				selectedfile = chooser.getSelectedFile();
				filePath = selectedfile.getAbsolutePath();
				
				break;
			case JFileChooser.CANCEL_OPTION :
				break; //in case of cancle
		}
	}
	public String getFileAbsolutePath()
	{
		return filePath;
	}
	public boolean CheckChoose(){
		if(choice == JFileChooser.APPROVE_OPTION)
			return true;
		else 
			return false;
	}
}
